import service from '@/utils/request'
import {ElMessage} from "element-plus/es";


export async function create(json: any) {
    const obj = {
        tableJson: {
            table: {
                name: 'hr_salary_data',
                child: [{table: {name: 'hr_salary_data_details'}}]
            }
        }
    };
    const res = await service({
        url: "sys/generator/createCode",
        method: "POST",
        params: {tableJson: "{table:{name:hr_salary_data,child:({table:{name:hr_salary_data_details}})}}"}
    })
    return res
}

const gencodeUrl = "sys/generator/code";
const dictColumnUrl = "sys/generator/dictionary";

export async function optGenerator(tableName: string | number) {
    if (tableName == null) {
        ElMessage.error("表名不能为空！");
        return;
    }
    const res = await service({
        url: gencodeUrl,
        method: "GET",
        params: {
            tables: tableName
        }
    })
    return res
}

export async function dictColumns(tableName: string | number) {
    if (tableName == null) {
        ElMessage.error("表名不能为空！");
        return;
    }
    const res = await service({
        url: dictColumnUrl,
        method: "GET",
        params: {
            tables: tableName
        }
    })
    return res
}
